import { read, write } from "ph-utils/file";
import { tgz } from "compressing";
import fs from "node:fs";

const pkg = await read("./package.json", {});
delete pkg["devDependencies"];
await write("./dist/package.json", pkg);

const tgzStream = new tgz.Stream();
const dirs = await fs.promises.readdir("dist", { encoding: "utf-8" });
for (const dir of dirs) {
  if (!dir.endsWith(".tgz")) {
    tgzStream.addEntry(`dist/${dir}`);
  }
}
tgzStream.pipe(fs.createWriteStream("dist/dist.tgz"));
